<?php

/**
 * This is the model class for table "collection".
 *
 * The followings are the available columns in table 'collection':
 * @property integer $id
 * @property string $no
 * @property integer $pid
 * @property string $scale
 * @property string $money
 * @property string $paytime
 * @property string $retime
 * @property string $reltime
 * @property integer $overdue
 * @property integer $reason
 * @property string $desc
 * @property integer $isdel
 */
class Collection extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'collection';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('pid, overdue, reason, isdel', 'numerical', 'integerOnly'=>true),
			array('no, scale', 'length', 'max'=>20),
			array('money', 'length', 'max'=>10),
			array('paytime, retime, reltime, desc', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, no, pid, scale, money, paytime, retime, reltime, overdue, reason, desc, isdel', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'no' => '编号',
			'pid' => '合同编号',
			'scale' => '回款比例',
			'money' => '回款金额',
			'paytime' => '合同规定付款日期',
			'retime' => '预计回款日期',
			'reltime' => '实际回款日期',
			'overdue' => '逾期时间',
			'reason' => '未回款原因',
			'desc' => '情况说明',
			'isdel' => 'Isdel',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('no',$this->no,true);
		$criteria->compare('pid',$this->pid);
		$criteria->compare('scale',$this->scale,true);
		$criteria->compare('money',$this->money,true);
		$criteria->compare('paytime',$this->paytime,true);
		$criteria->compare('retime',$this->retime,true);
		$criteria->compare('reltime',$this->reltime,true);
		$criteria->compare('overdue',$this->overdue);
		$criteria->compare('reason',$this->reason);
		$criteria->compare('desc',$this->desc,true);
		$criteria->compare('isdel',$this->isdel);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Collection the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
